// 导入axios
import axios from 'axios'
// 创建基地址
const request = axios.create({
  baseURL: 'https://autumnfish.cn'
})
// 抽取方法
// 轮播图
const carousel = ({ type }) =>
  request({
    url: '/banner',
    method: 'get',
    params: {
      type,
      timestamp: Date.now()
    }
  })
// 编辑推荐
const personalized = ({ limit }) =>
  request({
    url: '/personalized',
    method: 'get',
    params: {
      limit,
      timestamp: Date.now()
    }
  })
// 最新音乐
const newSong = ({ limit }) =>
  request({
    url: '/personalized/newsong',
    method: 'get',
    params: {
      limit,
      timestamp: Date.now()
    }
  })
// 歌曲详情
const getDetail = ids =>
  request({
    url: '/song/detail',
    method: 'get',
    params: {
      ids,
      timestamp: Date.now()
    }
  })
// 搜索关键词
const searchKeywords = keywords =>
  request({
    url: '/search',
    method: 'get',
    params: {
      keywords,
      limit: 10,
      timestamp: Date.now()
    }
  })
// 热搜列表
const searchHot = () =>
  request({
    url: '/search/hot',
    method: 'get'
  })

// 暴露
export { carousel, personalized, newSong, getDetail, searchKeywords, searchHot }
